.row
  .col-sm-6
    .panel.panel-default
      .panel-heading
        h5
          ' Public Profile
      .panel-body
        = form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: 'profile' }) do |f|
          - unless current_user.email?
            p
              | Your profile is not complete. Please, submit an email to be used in this Portus instance.
          .form-group class=(current_user.email? ? "" : "has-error")
            .field
              - if current_user.email?
                = f.label :email
              - else
                = f.label :email, "Email", class: "control-label", title: "This profile is not complete. You need to provide an email first"
              = f.email_field(:email, class: 'form-control', required: true, autofocus: true)

          - if APP_CONFIG.enabled?("display_name")
            .form-group
              .field
                = f.label :display_name
                = f.text_field(:display_name, class: 'form-control')

          .form-group
            .actions
              = f.submit('Update', class: 'btn btn-primary', disabled: true)

    #add_application_token_form.collapse
      = form_for :application_token, url: application_tokens_path, remote: true, html: {id: 'new-application-token-form', class: 'form-horizontal', role: 'form'} do |f|
          .form-group
            = f.label :application, {class: 'control-label col-md-2'}
            .col-md-7
              = f.text_field(:application, class: 'form-control', required: true, placeholder: "Name")
          .form-group
            .col-md-offset-2.col-md-7
              = f.submit('Create', class: 'btn btn-primary')

    .panel.panel-default
      .panel-heading
        .row
          .col-sm-6
            h5
              ' Application tokens
          .col-sm-6.text-right
            - if current_user.application_tokens.count >= User::APPLICATION_TOKENS_MAX
              a#add_application_token_btn.btn.btn-xs.btn-link.js-toggle-button[disabled="disabled" role="button"]
                i.fa.fa-plus-circle
                | Create new token
            - else
              a#add_application_token_btn.btn.btn-xs.btn-link.js-toggle-button[role="button"]
                i.fa.fa-plus-circle
                | Create new token
      .panel-body
        .table-responsive
          table.table.table-striped.table-hover
            colgroup
              col.col-90
              col.col-10
            thead
              tr
                th Application
                th Remove
            tbody#application_tokens
              - current_user.application_tokens.each do |token|
                = render partial: 'application_tokens/application_token', locals: {application_token: token}

    - if current_user.email?
      - unless current_user.admin? && @admin_count == 1
        .panel.panel-default
          .panel-heading
            h5
              ' Disable account
          .panel-body
            = form_tag(toggle_enabled_path(current_user), method: :put, remote: true, id: 'disable-form') do
                .form-group
                  p
                    | By disabling the account, you won't be able to access Portus with it, and
                      any affiliations with any team will be lost.
                  = submit_tag('Disable', class: 'btn btn-primary')

  - unless ::Portus::LDAP.enabled?
    - if current_user.email?
      .col-sm-6
        .panel.panel-default
          .panel-heading
            h5
              ' Change Password
          .panel-body
            = form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: 'password' }) do |f|
              - if devise_mapping.confirmable? && resource.pending_reconfirmation?
                div
                  Currently waiting confirmation for: #{resource.unconfirmed_email}
              .form-group
                .field
                  = f.label :current_password, class: 'control-label'
                  = f.password_field :current_password, autocomplete: 'off', class: 'form-control'
                  br
                .field
                  = f.label :password, class: 'control-label'
                  = f.password_field :password, autocomplete: 'off', class: 'form-control'
                  br
                .field
                  = f.label :password_confirmation, class: 'control-label'
                  = f.password_field :password_confirmation, autocomplete: 'off', class: 'form-control'
              .form-group
                .actions
                  = f.submit('Change', class: 'btn btn-primary', disabled: true)

